package run.iget.tools.web.code;

/**
 * Copyright (C), 2021，行动改变认知[iget.run]
 * 代码千万行，注释第一行
 * ----------------------------------------
 *
 * 基础公用的返回码
 *
 * @author 大周|450513554@qq.com
 * @since 2020/12/12 20:5609
 */
public interface BaseResponseCode {

    /**
     * 处理成功
     */
    ResponseStatus SUCCESS = new BaseResponseCode.ResponseStatus("0000", "处理成功");
    /**
     * 处理失败
     */
    ResponseStatus FAIL = new BaseResponseCode.ResponseStatus("-1", "通用错误");

    /****---------------系统异常或错误----------------------------****/
    ResponseStatus ERROR_400 = new BaseResponseCode.ResponseStatus("400", "请求参数错误");
    ResponseStatus ERROR_NO_TOKEN = new BaseResponseCode.ResponseStatus(ERROR_400.code, "token不可为空");
    ResponseStatus ERROR_INVALID_TOKEN = new BaseResponseCode.ResponseStatus(ERROR_400.code, "token无效");
    ResponseStatus ERROR_401 = new BaseResponseCode.ResponseStatus("401", "未认证");
    ResponseStatus ERROR_403 = new BaseResponseCode.ResponseStatus("403", "未授权");
    ResponseStatus ERROR_404 = new BaseResponseCode.ResponseStatus("404", "资源不存在");
    ResponseStatus ERROR_500 = new BaseResponseCode.ResponseStatus(FAIL.code, "系统处理异常，请稍后再试");
    ResponseStatus ERROR_BUSINESS_EXCEPTION = new BaseResponseCode.ResponseStatus(ERROR_500.getCode(), "系统处理异常");
    ResponseStatus ERROR_ARGUMENT_VALID = new BaseResponseCode.ResponseStatus(ERROR_500.getCode(), "参数校验失败");
    ResponseStatus ERROR_SQL_EXE = new BaseResponseCode.ResponseStatus(ERROR_500.getCode(), "SQL执行异常");
    ResponseStatus ERROR_DATA_SIGN = new BaseResponseCode.ResponseStatus(ERROR_500.getCode(), "数据签名错误");
    ResponseStatus ERROR_SERVICE_UNAVAILABLE = new BaseResponseCode.ResponseStatus("502", "服务不可用或请求超时");
    /****---------------系统异常或错误---------------end-------------****/

    /**
     * 返回状态内部类
     */
    class ResponseStatus {
        public ResponseStatus(String code, String msg) {
            this.code = code;
            this.msg = msg;
        }
        /**
         * 返回码
         */
        private String code;
        /**
         * 返回消息
         */
        private String msg;

        public String getCode() {
            return code;
        }

        public String getMsg() {
            return msg;
        }
    }

}
